package com.chcit.share.generator.service.impl;

import java.util.List;
import java.util.Map;

import com.chcit.share.generator.model.TemplateModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chcit.share.admin.core.page.MybatisPageHelper;
import com.chcit.share.admin.core.page.PageRequest;
import com.chcit.share.admin.core.page.PageResult;

import com.chcit.share.generator.dao.TemplateMapper;
import com.chcit.share.generator.service.TemplateService;

/**
 * ---------------------------
 * 模板 (TemplateServiceImpl)         
 * ---------------------------
 * 作者：  liuyang
 * 时间：  2019-05-05 14:52:47
 * 说明：  我是由代码生成器生生成的
 * ---------------------------
 */
@Service
public class TemplateServiceImpl implements TemplateService {

	@Autowired
	private TemplateMapper genTemplateMapper;

	@Override
	public int save(TemplateModel record) {
		if(record.getId() == null || record.getId() == 0) {
			return genTemplateMapper.add(record);
		}
		return genTemplateMapper.update(record);
	}

	@Override
	public int delete(TemplateModel record) {
		return genTemplateMapper.delete(record.getId());
	}

	@Override
	public int delete(List<TemplateModel> records) {
		for(TemplateModel record:records) {
			delete(record);
		}
		return 1;
	}

	@Override
	public TemplateModel findById(Long id) {
		return genTemplateMapper.findById(id);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest) {
		return MybatisPageHelper.findPage(pageRequest, genTemplateMapper);
	}

    @Override
    public List<TemplateModel> selectList(TemplateModel model) {
        return  genTemplateMapper.selectList(model);
    }

    @Override
    public List<TemplateModel> getTemplateByIds(String[] templates) {
        return genTemplateMapper.getTemplateByIds(templates);
    }

	@Override
	public List<Map<String, Object>> getList() {
		return genTemplateMapper.getList();
	}
}
